<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>采购指令</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table td {
			vertical-align: middle;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/ivm/purchase/list");
			$("#searchForm").submit();
        	return false;
        }
        //查看采购指令明细
        function showPurchaseDetail(id){
        	top.$.jBox.defaults.top="8%";
        	top.$.jBox.open("iframe:${ctx}/ivm/purchase/showPurchaseDetail?id="+id, "采购指令明细",$(top.document).width()-300,$(top.document).height()-100,{
				buttons:{"确定":true}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
        }
       //导出采购指令明细数据
       function exportPurchaseDetail(id){
			top.$.jBox.confirm("确认要导出采购指令明细数据吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$("#searchForm").attr("action","${ctx}/ivm/purchase/export?id="+id);
					$("#searchForm").submit();
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
		//打开添加采购质量面板
		function addPurchase(){
			top.$.jBox.defaults.top="8%";
        	top.$.jBox.open("iframe:${ctx}/ivm/purchase/showNewPurchase", "采购指令明细",$(top.document).width()-300,$(top.document).height()-100,{
				buttons:{"确定":true}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ivm/purchase/list">采购指令</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="purchase" action="${ctx}/ivm/purchase/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="searchParam" name="searchParam" type="text" value="${searchParam }" style="width: 410px;" placeholder="请输入采购指令编号、采购员姓名或手机号"/>
		<label>生成日期：</label>
		<input id="hopeDate" name="hopeDate" type="text" maxlength="50" class="input-small Wdate"
			onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});" value="${hopeDate }"/>
		<label>状态：</label>
		<form:select path="state" class="input-small">
			<form:option value="" label="请选择"/>
			<form:option value="0" label="采购中"/>
			<form:option value="1" label="已完成"/>
		</form:select>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" onclick="addPurchase()" value="添加采购指令"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>生成日期</th>
				<th>采购指令编号</th>
				<th>采购员</th>
				<th>供应商</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="purchase">
			<tr>
				<td><fmt:formatDate value="${purchase.createDate }" pattern="yyyy-MM-dd HH:mm"/></td>
				<td><a href="#" onclick="showPurchaseDetail('${purchase.id}')">${purchase.code }</a></td>
				<td>${purchase.member.name }</td>
				<td>${purchase.supplier.name }</td>
				<td style="text-align: center;">
					<c:if test="${purchase.state=='0'}">
					采购中	
					</c:if>
					<c:if test="${purchase.state=='1'}">
					已完成	
					</c:if>
				</td>
				<td>
					<a href="javascript:" onclick="exportPurchaseDetail('${purchase.id}')">导出</a>
					<c:if test="${purchase.state == '0'}">
<!-- 
					<a href="${ctx}/ivm/purchase/updateState?id=${purchase.id}&state=1" onclick="return confirmx('确定完成该采购指令采购？', this.href)">关闭</a>
					<a href="${ctx}/ivm/purchase/deletePurchase?id=${purchase.id}" onclick="return confirmx('确定删除该采购指令采购？', this.href)">删除</a>
					<a href="${ctx}/ivm/purchase/updateState?id=${purchase.id}&state=1" onclick="return confirmx('确定完成该采购指令？', this.href)">完成</a>
 -->
					<a href="${ctx}/ivm/purchase/delete?id=${purchase.id}" onclick="return confirmx('确定删除该采购指令？', this.href)">删除</a>
					</c:if>
					<c:if test="${purchase.state != '1'}">
					<a href="#" onclick="showPurchaseDetail('${purchase.id}')">入库</a>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>